﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Solution
{
    public class TreeNode
    {
        public int val;
        public TreeNode left;
        public TreeNode right;
        public TreeNode(int val = 0, TreeNode left = null, TreeNode right = null)
        {
            this.val = val;
            this.left = left;
            this.right = right;
        }

        //TreeNode resNode = null;
        //int maxDepth = 0;
        ///// <summary>
        ///// leetcode  1123  最深叶节点的公共祖先
        ///// </summary>
        ///// <param name="root"></param>
        ///// <returns></returns>
        //public TreeNode LcaDeepestLeaves(TreeNode root)
        //{
        //    DFSDepth(root, maxDepth);
        //    return resNode;
        //}

        //int DFSDepth(TreeNode node, int depth)
        //{
        //    if (node == null)
        //    {
        //        maxDepth = Math.Max(maxDepth, depth);
        //        return depth;
        //    }
        //    int leftDepth = DFSDepth(node.left, depth + 1);
        //    int rightDepth = DFSDepth(node.right, depth + 1);
        //    if (leftDepth == rightDepth && leftDepth == maxDepth)
        //    {
        //        resNode = node;
        //    }
        //    return Math.Max(leftDepth, rightDepth);
        //}
    }
}
